package com.dims_hsrc.web.controller.audit;

import com.dims_hsrc.audit.service.IContractRecordService;
import com.dims_hsrc.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/audit/contract")
public class ContractRecordController {

    @Autowired
    private IContractRecordService contractRecordService;

    /**
     * 替换合同文件
     */
    @PostMapping("/replace")
    public AjaxResult replaceContractFile(@RequestParam("contractNo") String contractNo,
                                        @RequestParam("file") MultipartFile file) {
        try {
            int rows = contractRecordService.replaceContractFile(contractNo, file);
            return rows > 0 ? AjaxResult.success() : AjaxResult.error("替换合同文件失败");
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }
} 